#include "GameConfig.h"
#include "logManager.h"
#include "netSocket.h"


GameConfig* gGameConfig = F_NULL;

GameConfig::GameConfig()
{
	gGameConfig = this;
}


fvoid			GameConfig::init( const fbyte* path )
{
    ptree pt;
    ptree login , guest;
    
    read_xml( path , pt , boost::property_tree::xml_parser::trim_whitespace );
    
    FLOG4( "xml loading. %s" , path );
    
    pt = pt.get_child( "config" );
    
    login = pt.get_child( "LoginMapPos" );
    guest = pt.get_child( "GuestData" );
    
    LoginMapPos.MapID = login.get<fint32>( "<xmlattr>.map" );
    LoginMapPos.Grid.x = login.get<fint32>( "<xmlattr>.x" );
    LoginMapPos.Grid.y = login.get<fint32>( "<xmlattr>.y" );
    
    GuestData.Vitality = guest.get<fint32>( "<xmlattr>.vit" );
    GuestData.Strength = guest.get<fint32>( "<xmlattr>.str" );
    GuestData.Toughness = guest.get<fint32>( "<xmlattr>.tgh" );
    GuestData.Dexterity = guest.get<fint32>( "<xmlattr>.dex" );
    GuestData.Level = guest.get<fint32>( "<xmlattr>.lv" );
    GuestData.Base.Fire = guest.get<fint32>( "<xmlattr>.fire" );
    GuestData.Base.Charm = guest.get<fint32>( "<xmlattr>.charm" );
    GuestData.Base.MAXHP = guest.get<fint32>( "<xmlattr>.hp" );
    GuestData.Base.MAXMP = guest.get<fint32>( "<xmlattr>.mp" );
    
    FLOG4( "xml loaded. %s" , path );
    
}

